home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2007 December
/
PCWKCD1207B.iso
/
Windows marzen
/
Maxthon 2.0.4
/
mx_2.0.4.5799.exe
/
template
/
_shared
/
js
/
func.js
next >
Wrap
Text File
|
2007-09-20
|
13KB
|
663 lines
function $clone(_1){
if(typeof _1!="object"){
return _1;
}
var _2;
if(_1 instanceof Array){
_2=[];
for(var i=0;i<_1.length;i++){
if(typeof _1[i]=="object"){
_2[i]=$clone(_1[i]);
}else{
_2[i]=_1[i];
}
}
}else{
_2={};
for(i in _1){
if(typeof _1[i]=="object"){
_2[i]=$clone(_1[i]);
}else{
_2[i]=_1[i];
}
}
}
return _2;
};
function $extend(_4,_5,_6){
var _7=$clone(_4);
if(typeof _7!="object"){
return _7;
}
for(var _8 in _5){
if(_7[_8]==undefined||_6){
_7[_8]=_5[_8];
}
}
return _7;
};
function $toJSON(_9,_a){
var _b={"indent":0,"indentText":"","delimiter":"","includeFunction":false};
_a=_a?$extend(_a,_b):_b;
var _c="";
var _d="";
if(_a["indentText"]!=""){
_a["indent"]++;
_d=new Array(_a["indent"]).join(_a["indentText"]);
_c=new Array(_a["indent"]+1).join(_a["indentText"]);
}
switch(typeof (_9)){
case "object":
if(_9 instanceof Array){
var _e=[];
for(var i=0;i<_9.length;i++){
var t=$toJSON(_9[i],_a);
if(t){
_e.push(_c+t);
}
}
_e="["+_a["delimiter"]+_e.join(","+_a["delimiter"])+_a["delimiter"]+_d+"]";
}else{
if(_9 instanceof Date){
return "new Date("+_9.getFullYear()+","+_9.getMonth()+","+_9.getDate()+","+_9.getHours()+","+_9.getMinutes()+","+_9.getSeconds()+","+_9.getMilliseconds()+")";
}else{
if(_9 instanceof Object){
var _e=[];
for(label in _9){
var l=$toJSON(label);
var t=$toJSON(_9[label],_a);
if(t){
_e.push(_c+l+": "+t);
}
}
_e="{"+_a["delimiter"]+_e.join(","+_a["delimiter"])+_a["delimiter"]+_d+"}";
}
}
}
break;
case "string":
var str=_9;
str=str.replace(/\\"/g,"\\\\\"");
str=str.replace(/\r/g,"\\r");
str=str.replace(/\t/g,"\\t");
str=str.replace(/\n/g,"\\n");
str=str.replace(/\f/g,"\\f");
str=str.replace(/\"/g,"\\\"");
_e="\""+str+"\"";
break;
case "number":
_e=isFinite(_9)?String(_9):"null";
break;
case "boolean":
_e=_9.toString();
break;
case "function":
if(_a["includeFunction"]){
_e=_9.toString();
}else{
_e="";
}
break;
case "null":
_e="null";
break;
}
return _e;
};
function $fromJSON(_13){
var obj;
try{
obj=eval("("+_13+")");
}
catch(e){
obj=null;
}
return obj;
};
function $dump(obj){
alert($toJSON(obj,{"indentText":" ","delimiter":"\n"}));
};
String.prototype.$repeat=function(_16){
return new Array(_16+1).join(this);
};
String.prototype.$trim=function(){
return this.replace(/^[\s\n\t]*|[\s\n\t]*$/g,"");
};
String.prototype.$charWidthAt=function(_17){
if(this.length<1){
return 0;
}
if(!_17){
_17=0;
}
var _18=this.charCodeAt(_17);
if(_18<32){
return 0;
}
if((_18>=4352&&_18<=4447)||(_18==9001||_18==9002)||(_18>=11904&&_18<=12350)||(_18>=12353&&_18<=19893)||(_18>=19968&&_18<=42182)||(_18>=44032&&_18<=57343)||(_18>=63744&&_18<=64217)||(_18>=65040&&_18<=65049)||(_18>=65072&&_18<=65131)||(_18>=65281&&_18<=65376)||(_18>=65504&&_18<=65518)){
return 2;
}
return 1;
};
String.prototype.$cut=function(_19,_1a){
var _1b={"addPoints":true,"pointsText":"...","reverse":false};
_1a=_1a?$extend(_1a,_1b):_1b;
var _1c=this.valueOf();
var _1d=0;
if(!_1a["reverse"]){
for(var i=0;(_1d<=_19)&&(i<this.length);i++){
_1d+=this.$charWidthAt(i);
}
_1c=_1c.substring(0,i);
}else{
for(var i=this.length-1;(_1d<=_19)&&(i>-1);i--){
_1d+=this.$charWidthAt(i);
}
_1c=_1c.substring(_1c.length-i,_1c.length);
}
if(_1a["addPoints"]&&_1c.length!=this.length){
if(!_1a["reverse"]){
_1c+=_1a["pointsText"];
}else{
_1c=_1a["pointsText"]+_1c;
}
}
return _1c;
};
String.prototype.$encodeHTML=function(_1f){
var _20=this.valueOf();
_20=_20.replace(/\&/g,"&");
_20=_20.replace(/\>/g,">");
_20=_20.replace(/\</g,"<");
_20=_20.replace(/\"/g,""");
_20=_20.replace(/\'/g,"'");
if(!_1f){
_20=_20.replace(/\n/g,"<br/>");
}
return _20;
};
String.prototype.$stripHTML=function(){
var _21=this.valueOf();
_21=_21.replace(/\<[^\<\>]+\>/g,"");
_21=_21.replace(/ +/g," ");
_21=_21.replace(/\n+/g,"\n");
return _21;
};
String.prototype.$sanitizeHTML=function(_22){
if(_22==undefined){
_22={"br":{},"b":{},"strong":{},"u":{},"em":{},"ul":{},"ol":{},"li":{},"blockquote":{"style":{invalid:"expression|script"}},"p":{"align":{valid:"left|center|right"},"style":{invalid:"expression|script"}},"span":{"style":{invalid:"expression|script"}},"div":{"align":{valid:"left|center|right"},"style":{invalid:"expression|script"}},"a":{"href":{valid:"^(http|https|ftp|mailto):"},"title":{},"target":{}},"img":{"src":{valid:"^(http|ftp):"},"alt":{}}};
}
var _23=this.valueOf();
_23=_23.replace(/[\x00-\x1f\x7f]/ig,"");
var re=/\<([^\/].*?)(\/)?\>/ig;
while((arrMatch=re.exec(_23))!=null){
var _25=arrMatch[1].length;
var _26=arrMatch[1].split(" ");
var _27="";
for(var _28 in _22){
var _29=_26[0];
if(_22[_29]){
for(var i=1;i<_26.length;i++){
var pos=_26[i].indexOf("=");
if(pos<1){
_26.splice(i,1);
i--;
}else{
var _2c=_26[i].substr(0,pos);
var _2d=_26[i].substr(pos+1,_26[i].length);
if(_2d.indexOf("\"")==0||_2d.indexOf("'")==0){
_2d=_2d.substr(1,_2d.length);
_2d=_2d.substr(0,_2d.length-1);
}
if(_22[_29][_2c]){
if(_22[_29][_2c].valid){
var _2e=new RegExp(_22[_29][_2c].valid,"ig");
if(!_2e.test(_2d)){
_26.splice(i,1);
i--;
continue;
}
}
if(_22[_29][_2c].invalid){
var _2e=new RegExp(_22[_29][_2c].invalid,"ig");
if(_2e.test(_2d)){
_26.splice(i,1);
i--;
continue;
}
}
_2d=_2d.replace(/\"/ig,""");
_26[i]=_2c+"=\""+_2d+"\"";
}else{
_26.splice(i,1);
i--;
}
}
}
_27="<"+_26.join(" ")+arrMatch[2]+">";
}else{
_27="";
}
}
_23=_23.replace(arrMatch[0],_27);
re.lastIndex+=_27.length-_25;
}
return _23;
};
String.prototype.$sanitizeURL=function(){
var _2f=this.valueOf();
var re=/^(.*?)script:/ig;
if(re.test(_2f)){
return "";
}
re=/^about:/ig;
if(re.test(_2f)){
return "";
}
_2f=_2f.replace(/</ig,"%3C");
_2f=_2f.replace(/>/ig,"%3E");
_2f=_2f.replace(/ /ig,"%20");
return _2f;
};
String.prototype.$safeQuote=function(_31){
var _32=this.valueOf();
if(_31){
_32=_32.replace(/\'/ig,"\\'");
}else{
_32=_32.replace(/\"/ig,"\\\"");
}
return _32;
};
$Date={};
$Date.names={};
$Date.names.weekday=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
$Date.names.weekdayAbbr=["Sun","Mon","Tue","Wedy","Thu","Fri","Sat"];
$Date.names.month=["January","February","March","April","May","June","July","August","September","October","November","December"];
$Date.names.monthAbbr=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
$Date.names.ampm=["AM","PM"];
$Date.names.ampmAbbr=["A","P"];
$Date.parse=function(_33){
var _34=new Date();
var _35=0;
var _36;
var _37;
_33=_33.split(" ");
if(_33.length==2){
_36=_33[0];
_37=_33[1];
}else{
if(_33.length==1){
_36=_33[0];
_37="";
}else{
return null;
}
}
_36=_36.split("-");
if(_36.length!=3){
return null;
}else{
_35=parseInt(_36[0],10);
if(_35!=NaN){
_34.setFullYear(_35);
}
_35=parseInt(_36[1],10);
if(_35!=NaN){
_34.setMonth(_35-1);
}
_35=parseInt(_36[2],10);
if(_35!=NaN){
_34.setDate(_35);
}
}
_37=_37.split(":");
if(_37.length==3){
_35=parseInt(_37[0],10);
if(_35!=NaN){
_34.setHours(_35);
}
_35=parseInt(_37[1],10);
if(_35!=NaN){
_34.setMinutes(_35);
}
_35=parseInt(_37[2],10);
if(_35!=NaN){
_34.setSeconds(_35);
}
}
return _34;
};
Date.prototype.$toString=function(_38,_39){
var _3a={"names":$Date.names,"toUTC":false,"UTC":""};
_39=_39?$extend(_39,_3a):_3a;
if(!_38){
_38="CWA14051-1";
}
switch(_38){
case "CWA14051-1":
_38="yyyy-MM-dd HH:mm:ss";
break;
case "RFC1123":
_38="ddd, dd MMM yyyy HH:mm:ss zzz";
_39["toUTC"]=true;
_39["UTC"]="GMT";
break;
case "W3C":
case "ISO8601":
_38="yyyy-MM-ddTHH:mm:sszzzz";
_39["UTC"]="Z";
break;
}
var _3b=new Date(Number(this));
if(_39["toUTC"]){
_3b.setMinutes((_3b.getMinutes()+_3b.getTimezoneOffset()));
}
var _3c={};
_3c["d"]=_3b.getDate();
_3c["dd"]=_3c["d"]<10?"0"+_3c["d"]:_3c["d"];
_3c["ddd"]=_39["names"].weekdayAbbr[_3b.getDay()];
_3c["dddd"]=_39["names"].weekday[_3b.getDay()];
_3c["M"]=_3b.getMonth()+1;
_3c["MM"]=_3c["M"]<10?"0"+_3c["M"]:_3c["M"];
_3c["MMM"]=_39["names"].monthAbbr[_3b.getMonth()];
_3c["MMMM"]=_39["names"].month[_3b.getMonth()];
_3c["yyyy"]=_3b.getFullYear();
_3c["y"]=_3c["yyyy"]%100;
_3c["yy"]=_3c["y"]<10?"0"+_3c["y"]:_3c["y"];
_3c["H"]=_3b.getHours();
_3c["HH"]=_3c["H"]<10?"0"+_3c["H"]:_3c["H"];
_3c["h"]=_3c["H"]>12?_3c["H"]-12:_3c["H"];
_3c["hh"]=_3c["h"]<10?"0"+_3c["h"]:_3c["h"];
_3c["t"]=_3c["H"]>12?_39["names"].ampm[1]:_39["names"].ampm[0];
_3c["tt"]=_3c["H"]>12?_39["names"].ampmAbbr[1]:_39["names"].ampmAbbr[0];
_3c["m"]=_3b.getMinutes();
_3c["mm"]=_3c["m"]<10?"0"+_3c["m"]:_3c["m"];
_3c["s"]=_3b.getSeconds();
_3c["ss"]=_3c["s"]<10?"0"+_3c["s"]:_3c["s"];
_3c["f"]=_3b.getMilliseconds();
var _3d=_3b.getTimezoneOffset()<0?"+":"-";
var _3e=Math.abs(Math.round(_3b.getTimezoneOffset()/60));
var _3f=_3b.getTimezoneOffset()%60;
_3c["z"]=_3d+_3e;
_3c["zz"]=_3d+(_3e<10?"0"+_3e:_3e);
_3c["zzz"]=_3c["zz"]+(_3f<10?"0"+_3f:_3f);
_3c["zzzz"]=_3c["zz"]+":"+(_3f<10?"0"+_3f:_3f);
if(_39["toUTC"]||(_39["UTC"]!=""&&_3b.getTimezoneOffset()==0)){
_3c["z"]=_3c["zz"]=_3c["zzz"]=_3c["zzzz"]=_39["UTC"];
}
var _40="";
var pos=0;
while(pos<_38.length){
var _42=_38.charAt(pos);
var _43="";
while((_38.charAt(pos)==_42)&&(pos<_38.length)){
_43+=_42;
pos++;
}
if(_3c[_43]){
_40+=_3c[_43];
}else{
_40+=_43;
}
}
return _40;
};
Array.prototype.$contains=function(_44){
return this.$indexOf(_44)>-1?true:false;
};
Array.prototype.$indexOf=function(_45){
for(var i=0;i<this.length;i++){
if(this[i]==_45){
return i;
}
}
return -1;
};
Array.prototype.$sort=function(key,_48){
var _49={"compareLength":false,"descending":false};
_48=_48?$extend(_48,_49):_49;
if(key==undefined){
this.sort();
}else{
this.sort(function(_4a,_4b){
var t1=_4a[key];
var t2=_4b[key];
if(_48["compareLength"]){
if(t1.length>t2.length){
return 1;
}
if(t1.length<t2.length){
return -1;
}
}
if(t1>t2){
return 1;
}
if(t1==t2){
return 0;
}
return -1;
});
}
if(_48["descending"]){
this.reverse();
}
};
function $id(){
var _4e;
if(arguments.length==1){
_4e=document.getElementById(arguments[0]);
if(!_4e){
_4e=null;
}
}else{
_4e=[];
for(var i=0;i<arguments.length;i++){
var obj=document.getElementById(arguments[i]);
if(obj){
_4e.push(obj);
}
}
if(_4e.length<1){
_4e=null;
}
}
return _4e;
};
function $name(_51){
var _52=[];
for(var i=0;i<arguments.length;i++){
var _54=document.getElementsByName(arguments[i]);
_52=_52.concat(_54);
}
if(_54.length<1){
_54=null;
}
return _54;
};
function $event(_55,_56,obj,_58){
if(!obj){
obj=window;
}
if(!_56||!_58){
return;
}
if(_55=="+"){
if(window.attachEvent){
obj.attachEvent("on"+_56,_58);
}else{
obj.addEventListener(_56,_58,false);
}
}else{
if(window.detachEvent){
obj.detachEvent("on"+_56,_58);
}else{
obj.removeEventListener(_56,_58,false);
}
}
};
function $write(_59,id,_5b){
if(id){
var obj=$id(id);
if(obj){
if(_5b){
obj.innerHTML+=_59;
}else{
obj.innerHTML=_59;
}
return;
}
}
document.write(_59);
};
var $langDefaultSection="";
function $lang(_5d,_5e){
if(!_5e){
_5e=$langDefaultSection;
}
try{
var str=external.max_Lang(_5e,_5d);
}
catch(e){
str="";
}
if(str==""){
str="["+_5d+"@"+_5e+"]";
}
return str;
};
function $writeLang(_60,_61){
document.write($lang(_60,_61));
};
function $parseQueryString(){
var _62=String(document.location);
var _63={};
var pos=_62.indexOf("?");
if(pos<0){
return _63;
}
var _65=_62.substr(pos+1,_62.length);
_65=_65.split("&");
for(var i=0;i<_65.length;i++){
pos=_65[i].indexOf("=");
var key=_65[i].substr(0,pos);
var _68=_65[i].substr(pos+1,_65[i].length);
_63[key]=_68;
}
return _63;
};
function $cookies(_69,_6a,ttl){
if(_6a==undefined){
var _6c=document.cookie.split("; ");
for(var i=0;i<_6c.length;i++){
var _6e=_6c[i].split("=");
if(_6e[0]==_69){
return _6e[1];
}
}
return null;
}else{
if(_6a==null){
document.cookie=_69+"=;expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/";
}else{
if(!ttl){
ttl=30;
}
var _6f=new Date();
_6f.setTime(_6f.getTime()+(ttl*24*60*60*1000));
document.cookie=_69+"="+_6a+"; expires="+_6f.toGMTString()+"; path=/";
}
}
};
function $toggleElement(id,_71,_72){
var obj=document.getElementById(id);
if(!obj){
return false;
}
if(!_72){
_72="block";
}
switch(_71){
case "show":
obj.style.display=_72;
return true;
break;
case "hide":
obj.style.display="none";
return false;
break;
default:
if(obj.style.display!="none"){
obj.style.display="none";
return false;
}else{
obj.style.display=_72;
return true;
}
}
};
function $decodeHTMLEntities(_74){
var ta=document.createElement("textarea");
ta.innerHTML=_74.replace(/</g,"<").replace(/>/g,">");
_74=ta.value;
delete ta;
return _74;
};
function $pageLinks(_76,_77,_78,_79,_7a){
if(_79==undefined){
_79=5;
}
if(_7a==undefined){
_7a={};
_7a["separator"]=" ";
_7a["normal"]="<a href=\"?page=%page\"> %page </a>";
_7a["active"]="<a href=\"#\" class=\"buttons-active\"> %page </a>";
_7a["prev"]="<a href=\"?page=%page\"> ‹ </a>";
_7a["next"]="<a href=\"?page=%page\"> › </a>";
_7a["first"]="<a href=\"?page=%page\"> « </a>";
_7a["last"]="<a href=\"?page=%page\"> » </a>";
}
var _7b=Math.floor((_76-1)/_77)+1;
var _7c="";
var _7d=_78-Math.floor(_79/2);
var _7e=_78+Math.floor(_79/2);
if(_7d<=0){
_7d=1;
_7e=_79;
}
if(_7e>_7b){
_7e=_7b;
_7d=_7b-_79;
}
if(_7d<=0){
_7d=1;
}
if(_7b==1){
_7c=_7a["active"].replace(/\%page/ig,"1");
}else{
if(_7d>1){
_7c+=_7a["first"].replace(/\%page/ig,"1")+_7a["separator"];
}
if(_78>1){
_7c+=_7a["prev"].replace(/\%page/ig,(_78-1))+_7a["separator"];
}
for(var i=_7d;i<=_7e;i++){
if(_78==i){
_7c+=_7a["active"].replace(/\%page/ig,i)+_7a["separator"];
}else{
if(i<=_7b){
_7c+=_7a["normal"].replace(/\%page/ig,i)+_7a["separator"];
}
}
}
if(_78<_7b){
_7c+=_7a["next"].replace(/\%page/ig,(_78+1));
}
if(_7e<_7b){
_7c+=_7a["separator"]+_7a["last"].replace(/\%page/ig,_7b);
}
}
return _7c;
};